<?php

class Control_Projects extends QUI_Control_Abstract
{
    function render()
    {
        $order = $this->get('order', 'updated DESC');
        $length = $this->get('len', 10);

        $this->_view['title'] = $this->get('title', 'projects');
        $this->_view['more_url'] = url('projects/index', array(
            'order' => implode('-', explode(' ', strtolower($order)))
        ));
        $this->_view['projects'] = Project::find('is_approbated = ?', true)
                                            ->order($order)->top($length)->getAll();
        return $this->_fetchView(dirname(__FILE__) . '/projects_view.php');
    }
}

